home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
551-575
/
apd566
/
ascii
/
input procs i.doc
< prev
next >
Wrap
Text File
|
1994-01-01
|
6KB
|
111 lines
*** I N P U T P R O C E D U R E S ( V O L U M E I ) ***
Written in 1993 for AMOS Basic by Glenn N Babic
The above named program contains two input devices of my own creation. I have
editted them for submission to the PD library so they are much easier for other
programmers to implement into their own programs. I have created other input
devices, but they are not yet suitably versatile for submitting (when they are
they will make up volume II). The input devices I've submitted here are a
single-line text inputer, a word-wrap window text inputer, and buttons:
The Text Inputers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These procedures allow the user to input text from the keyboard in a neat
fashion. Both the single-line windows and the more versitile word-wrap windows
allow the cursor to be moved about the text with the cursor keys and the mouse.
Text entered into a single-line window may extend past the ends of the text
window. If you wish to edit text beyond the ends of the window, simply move the
cursor in the appropriate direction and the window will scroll automatically to
reveal hidden text.
When entering text into a word-wrap window, long lines will be broken between
words on spaces so the entire text is displayed in an attractive and readable
form. However, words longer than the character width of the window will be
split within the word. To edit text hidden above or below the visible window
area, move the cursor in the appropriate direction to reveal it.
Note:
The text windows in this program can be activated by clicking in them with the
mouse, and deactivated by clicking the mouse outside of the text window or by
pressing RETURN (Obviously, this means that RETURN characters cannot be dis-
played in the windows. I, myself, simply type the ® symbol (Alt + R) in place
of it and use a routine that recognises them as marking the end of a paragraph
later in programs that use the inputed text (such as an adventure game) where
the paragraphed, inputed text could be a room description. My method proves
fine for a utility that sets up string data for such a program, however I
realise for a word processor it would not be appropriate. Also you cannot type
in TABs. PS: I have already began planning an input routine that handles RETURN
characters. Look out for it (hopefully in the form of a text editor) in the
near future!). If you use these text input procedures, you can change them so
that you don't have to click with the mouse to activate them (see below).
Important Technical:
The variables used in the calls to the Procedure WRAP_INPUT[S$,X,Y,W,H,M,Z] and
the Procedure LINE_INPUT[S$,X,Y,W,M,Z] are:
S$ = The text displayed in the window initially
X,Y = The co-ordinates of the top-left corner of the window
W = The width of the window (in characters)
H = The heigth of the window (in characters / word-wrap windows only)
M = The maximum allowed length of the text input (set to less than W for
single-line windows if you wish for no scroll)
Z = The zone associated with the window (used for mouse detection)
(by passing a value of -1 for Z when calling these procedures, the text
will be displayed, but the procedure will be exited immediately so that
no input is processed - this is useful so the window and any text can
be displayed initially, and then allowing the user to edit it if he/she
so wishes.
This program uses several windows, with their corresponding variables stored in
arrays, so that you can see how it is possible to display and edit multiple
windows at once. If you just wish to edit one window at a time in your own
program, you may wish to erase the initial calls to the procedures (where
Z=True) and the routine which checks for mouse clicks in the windows.
Buttons
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When the mouse is moved over a button (while no text window is being editted and
if the button is enabled) the border will be highlighted. Then if the left
mouse button is clicked, the text in the button will be highlighted and the
button will be activated. What happens next depends on the type of button: The
text on an instant flash button will immediately darken again, while a 'switch'
type button will be highlighted if initially dark, or darkened if initially
highlighted.
Important Technical:
The variables used in the call to the button procedures are:
I = The number of the button
T$ = The text displayed on the button (extra spaces widen button)
X,Y = The co-ordinates of the centre of the button
The data for the buttons are held in arrays. Most importantly, BUT_F() is a
flag determining the type of button:
1 = OFF ('switch')
2 = ON ('switch')
3 = quick flash
-ve = disabled (absolute value is used when button is enabled)
Calls can be made to different procedures for each button in the Procedure
ACTIVATE_BUTTON[I].
Final Important Notes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I decided on a four colour (grey scaled), hires screen for this program as it
allows for an attractive, light sourced, screen while not consuming too much
memory. The text cursor I made so it appears the character it is on, including
the background, is highlighted as if by a spotlight. However you may not like
some, or all, aspects of this display. You shouldn't find changing them too
difficult.
I have worked hard (mainly on the word-wrap window inputer) trying to find the
best and fastest way of creating such routines. I have erradicated all the bugs
I have found in this program, however I'm sure some more will pop up! If so,
and you would like me to fix the problem (as you probably don't understand my
programming) then contact me!
- Glenn N Babic
Reg. #1646